package cn.tac.framework.core.spring.config;

import cn.tac.framework.core.constant.GlobalConstant;
import cn.tac.framework.core.spring.bean.BizDataInterface;
import cn.tac.framework.core.spring.bean.DummyBizDataInterface;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.text.SimpleDateFormat;

/**
 * 与框架相关的配置
 *
 * @author : tac
 * @since : 2017/7/14
 */

@Configuration
public class FrameworkConfiguration {
    @Bean
    @ConditionalOnMissingBean
    public BizDataInterface bizDataInterface(){
        return new DummyBizDataInterface();
    }

    @Bean
    @ConditionalOnMissingBean
    public ObjectMapper objectMapper(){
        ObjectMapper bean = new ObjectMapper();
        bean.setDateFormat(new SimpleDateFormat(GlobalConstant.DATE_TIME_FORMAT_PATTERN));    //日期格式化器
        return bean;
    }
}
